#include "Poco/Notification.h"
#include "Poco/NotificationQueue.h"
#include "Poco/TimedNotificationQueue.h"
#include "Poco/Thread.h"
#include "eventnotification.h"

#include "iostream"

using namespace cm_base;

int main()
{
    Poco::Notification * p_no = new Poco::Notification;
    
    std::cout<<p_no->referenceCount();
    p_no->duplicate();

    Poco::NotificationQueue nq;

    nq.enqueueNotification( p_no );
    nq.enqueueNotification( p_no );

    std::cout<<p_no->referenceCount();

    p_no = nq.waitDequeueNotification(0);

    std::cout<<p_no->referenceCount()<<std::endl;

    std::cout<<"****************************************"<<std::endl;

    Poco::NotificationQueue nq2;
    EventNotification* p_event = new EventNotification;
    std::cout<<p_event->referenceCount()<<std::endl;

    Notification::Ptr p = p_event;
    nq2.enqueueNotification(p);

    std::cout<<p_event->referenceCount()<<std::endl;


    return 0;
}

int main2()
{
    Poco::TimedNotificationQueue nq;

    Poco::Notification* p_no = new Poco::Notification;
    
    Poco::Timestamp ts;
    Poco::Thread::sleep(200);
    std::cout<<"passed "<< ts.elapsed()<<std::endl;
    ts +=4000000;
    nq.enqueueNotification( p_no, ts);

    std::cout<<"before wait\n";

    nq.waitDequeueNotification();

    std::cout<<"after wati\n";

    return 0;
}